package com.qianxx.component.activity.recycleview.recycler_banner;

import android.os.Bundle;
import android.support.v7.widget.RecyclerView;

import com.qianxx.component.R;
import com.qianxx.component.activity.base.BaseActivity;
import com.qianxx.viewlibrary.recyclerview.banner.BannerLayout;
import com.qianxx.viewlibrary.recyclerview.banner.layoutmanager.CenterScrollListener;
import com.qianxx.viewlibrary.recyclerview.banner.layoutmanager.OverFlyingLayoutManager;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class RecyclerBannerActivity extends BaseActivity {
    @BindView(R.id.recycler)
    BannerLayout recycler;
    @BindView(R.id.recycler_ver)
    BannerLayout recyclerVer;

    OverFlyingLayoutManager mOverFlyingLayoutManager;
    @BindView(R.id.recycler_banner)
    RecyclerView recyclerBanner;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_recycler_banner);
        ButterKnife.bind(this);

        List<Integer> list = new ArrayList<>();
        list.add(R.drawable.p1);
        list.add(R.drawable.p2);
        list.add(R.drawable.p3);
        list.add(R.drawable.p4);
        list.add(R.drawable.p5);
        list.add(R.drawable.p6);
        list.add(R.drawable.p7);
        list.add(R.drawable.p8);

        BannerAdapter bannerAdapter = new BannerAdapter(this, list);
        recycler.setAdapter(bannerAdapter);
        recyclerVer.setAdapter(bannerAdapter);
        bannerAdapter.setOnBannerItemClickListener(new BannerLayout.OnBannerItemClickListener() {
            @Override
            public void onItemClick(int position) {

            }
        });

        mOverFlyingLayoutManager = new OverFlyingLayoutManager(0.65f, 350, OverFlyingLayoutManager.HORIZONTAL);
        //设置间距
        //mOverFlyingLayoutManager.setItemSpace(500);
        recyclerBanner.setAdapter(new BannerAdapter2(this, list));
        recyclerBanner.setLayoutManager(mOverFlyingLayoutManager);
        recyclerBanner.addOnScrollListener(new CenterScrollListener());
        mOverFlyingLayoutManager.setOnPageChangeListener(new OverFlyingLayoutManager.OnPageChangeListener() {

            @Override
            public void onPageSelected(int position) {

            }

            @Override
            public void onPageScrollStateChanged(int state) {

            }
        });

        //滑动到指定位置
        //mOverFlyingLayoutManager.smoothScrollToPosition(recyclerBanner,null,currentPosition);

    }

    @Override
    public String setTitle() {
        return "RecyclerBanner";
    }
}
